package com.simp.page;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.simp.expection.GlobalException;
import org.apache.logging.log4j.util.Strings;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author pan.shun
 * @since 2022/3/14 17:00
 */
public class SuperController {
    public SuperController() {
    }

    public <T> R<T> success(T data) {
        return R.success(data);
    }

    public <T> R<T> success() {
        return R.success();
    }

    public <T> R<T> error() {
        return R.error();
    }

    public List<String> convert(String idStr) {
        if (Strings.isBlank(idStr)) {
            throw new GlobalException("id不允许为空");
        } else {
            String[] idStrArr = StringUtils.split(idStr, "-");
            return (List) Arrays.stream(idStrArr).map((id) -> {
                return id;
            }).collect(Collectors.toList());
        }
    }
}
